#include <string>
#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    vector<int> mul(vector<int> &A, vector<int> &B)
    {
        vector<int> C(A.size() + B.size() + 10, 0);

        for (int i = 0; i < A.size(); ++i)
        {
            for (int j = 0; j < B.size(); ++j)
            {
                C[i + j] += A[i] * B[j];
            }
        }

        int t = 0;
        for (int i = 0; i < C.size(); i++)
        {
            t += C[i];
            C[i] = t % 10;
            t /= 10;
        }
        while (C.size() > 1 && C.back() == 0)
        {
            C.pop_back();
        }
        return C;
    }

    string multiply(string num1, string num2)
    {
        if (num1 == "0" || num2 == "0")
        {
            return "0";
        }
        string ret;
        vector<int> A, B, C;
        for (int i = num1.size() - 1; i >= 0; --i)
        {
            A.push_back(num1[i] - '0');
        }
        for (int i = num2.size() - 1; i >= 0; --i)
        {
            B.push_back(num2[i] - '0');
        }
        C = mul(A, B);
        for (int i = C.size() - 1; i >= 0; --i)
        {
            ret += C[i] + '0';
        }
        return ret;
    };
};

int main()
{
    Solution a;
    cout << a.multiply("123", "456") << endl;
    return 0;
}